﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="import.ascx.cs" Inherits="basecon_import" %>
<div>
    <asp:HiddenField ID="hidFunction" runat="server" />
    <asp:HiddenField ID="hidImportType" runat="server" />
    <div>
        <asp:HyperLink ID="hlImport" runat="server" NavigateUrl="javascript:void(0)">HyperLink</asp:HyperLink></div>
    <div style="display: none; text-align: center" class="divImport">
        <div class="close">
            <asp:Image ID="imgX" runat="server" ImageUrl="~/images/x.gif" /></div>
        <div style="text-align: left; margin-top: 10px">
            <div style="float: left">
                <asp:Label ID="labText" runat="server" Text="Label" Font-Bold="True" Font-Size="Medium"
                    ForeColor="#8080FF"></asp:Label></div>
            <div style="float: right">
                <asp:HyperLink ID="hlTemplage" runat="server">下载模板</asp:HyperLink></div>
        </div>
        <div style="clear: both">
        </div>
        <div style="margin-top: 10px">
            <div>
                <asp:FileUpload ID="fuFile" runat="server" Width="200px" />
                <input type="button" value="导入" onclick="return <%=this.FunctionName %>();" />
            </div>
            <div style="display: none">
                <asp:Image ID="imgLoading" runat="server" ImageUrl="~/images/loading.gif" /></div>
            <div style="display: none">
            </div>
            <div style="display: none">
                <input type="button" id="btnReUpload" runat="server" value="重新上传" />
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
	function <%=this.FunctionName %>()
	{
        $("#<%=this.imgLoading.ClientID %>").parent().prev().hide();
        $("#<%=this.imgLoading.ClientID %>").parent().show();
		$("#<%=this.imgLoading.ClientID %>").parent().next().next().hide();
		$.ajaxFileUpload
		(
			{
				url:'<% Response.Write(Params.RootHttp + "import.aspx?type="+this.ImportType); %>',
				secureuri:false,
				fileElementId:'<%=this.fuFile.ClientID %>',
				dataType: 'json',
				data:{name:'logan', id:'id'},
				success: function (data, status)
				{
					if(typeof(data.error) != 'undefined')
					{
						if(data.error != '')
						{
							$("#<%=this.imgLoading.ClientID %>").parent().next().html(decodeURI(data.error));
						}else
						{
							//alert(data.msg);
							var ss=data.msg.split(",");
							$("#<%=this.imgLoading.ClientID %>").parent().next().html("<p>成功导入"+ss[0]+"条记录</p><p><a href='"+ss[1]+"'>下载导入信息</a>");
							//alert(htmlDecode(data.msg));
						}
					}
			        $("#<%=this.imgLoading.ClientID %>").parent().hide();
		            $("#<%=this.imgLoading.ClientID %>").parent().next().show();
		            $("#<%=this.imgLoading.ClientID %>").parent().next().next().show();
				},
				error: function (data, status, e)
				{
				    $("#<%=this.imgLoading.ClientID %>").parent().next().html(e);
			        $("#<%=this.imgLoading.ClientID %>").parent().hide();
		            $("#<%=this.imgLoading.ClientID %>").parent().next().show();
		            $("#<%=this.imgLoading.ClientID %>").parent().next().next().show();
				}
			}
		)
		
		return false;

	}

$(document).ready(function(){
    $("#<%=this.hlImport.ClientID %>").click(function(){
		$("#<%=this.imgLoading.ClientID %>").parent().prev().show();
		$("#<%=this.imgLoading.ClientID %>").parent().hide();
		$("#<%=this.imgLoading.ClientID %>").parent().next().hide();
		$("#<%=this.imgLoading.ClientID %>").parent().next().next().hide();
        $.blockUI({ message: $("#<%=this.imgLoading.ClientID %>").parent().parent().parent(),target: "#form1" });
    });
    $("#<%=this.btnReUpload.ClientID %>").click(function(){
		$("#<%=this.imgLoading.ClientID %>").parent().prev().show();
		$("#<%=this.imgLoading.ClientID %>").parent().hide();
		$("#<%=this.imgLoading.ClientID %>").parent().next().hide();
		$("#<%=this.imgLoading.ClientID %>").parent().next().next().hide();
	});
	$(".close").click(function(){$.unblockUI();});
});
</script>

